
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="<?php echo yii::app()->theme->baseUrl;  ?>/assets/css/common.css">
<script src="<?php echo yii::app()->theme->baseUrl;  ?>/assets/js/jquery-1.11.1.min.js"></script>
    <link rel="stylesheet" href="<?php echo yii::app()->theme->baseUrl;  ?>/assets/statics/js/artDialog6/css/ui-dialog.css">    
    <script src="<?php echo yii::app()->theme->baseUrl;  ?>/assets/statics/js/artDialog6/js/dialog-min.js"></script> 
    <style type="text/css">
        .position{
            position: relative;
        }
    </style>
</head>
<body>
<div <?php  if($type ==1){echo "style='display:none'";}  ?>class="login-content">
	<?php $objFormLogin = $this->beginWidget( 'CActiveForm', array('id' => 'SubmitFormLogin')); ?>
        <input name="type" type="hidden" value="<?php echo $type ?>">
		<div class="login-account">
			<input type="text" name="UserName" value="<?php  echo $login_model->UserName; ?>" class="login-acc" placeholder="邮箱/手机号/用户名">
            <?php echo $objFormLogin->error($login_model,'UserName', array('class' => 'login-acc-text')); ?>
        </div>
        <div class="login-pw" style="margin-bottom:8px;">
            <input type="Password" name="Password"  class="login-pww"  placeholder="密码">
            <?php echo $objFormLogin->error($login_model,'Password', array('class' => 'login-acc-text')); ?>
        </div>

        <!-- 邮箱验证 -->
        <div id="" style="" class="position login-codeForPhone">
            <input name="VerifyCode"  value="<?php echo $login_model->VerifyCode; ?>" type="text" class="login-forphone"  placeholder="验证码">
            <?php echo $objFormLogin->error($login_model,'VerifyCode', array('class' => 'login-acc-text')); ?>
        </div>
        <div id="" style="top:140px" class="register-time">
            <!-- <span>重新发送</span>
            <strong>49</strong> -->
            <em><?php $this->widget('CCaptcha',array('showRefreshButton'=>true,'clickableImage'=>true,'buttonLabel'=>false));  ?></em>
        </div>



        <a href="<?php  echo $this->createUrl('findPassword');  ?>" title="妈咪街账号登录" style="margin-top:12px;margin-bottom: 8px;margin-right: 6px;float: right;text-decoration: none;font-size:12px;color:#ffafc0;">忘记密码？</a>
        <div class="login-submit">
            <button>登录</button>
        </div>
        <div class="login-register">
            <a >注册</a>
        </div>

    <?php $this->endWidget(); ?>
</div>
<div <?php  if($type !=1){echo "style='display:none'";}  ?>class="register-content">
    
    <?php $objForm = $this->beginWidget( 'CActiveForm', array('id' => 'SubmitForm')); ?>
        <input name="type" type="hidden" value="<?php echo $type ?>">
        <div class="position register-account-B">
            <input name="UserName" type="text" class="register-aB" value="<?php echo $register_model->UserName; ?>" placeholder="用户名">
            <?php echo $objForm->error($register_model,'UserName', array('class' => 'login-acc-text')); ?>        
        </div>
        <div class="position login-account">
            <input id="EmailPhone"  value="<?php echo $register_model->EmailPhone; ?>" name="EmailPhone" type="text" class="login-acc" placeholder="邮箱/手机号">
            <?php echo $objForm->error($register_model,'EmailPhone', array('class' => 'login-acc-text')); ?>
        </div>


        <script type="text/javascript">

            function getNum(){
                var value = $("[name='EmailPhone']").val();
                if(value.length == 11 && !isNaN(value)){
                    $("#VerifyCode").hide();
                    $("#Code_img").hide();
                    $("#PhoneCode").show();
                    $("#snscode_div").show();
                }else{
                    $("#VerifyCode").show();
                    $("#Code_img").show();
                    $("#PhoneCode").hide();
                    $("#snscode_div").hide();
                }                
            }
            $(function(){
                getNum();
                //失去焦点的时候
                $("[name='EmailPhone']").focusout(function(){
                    getNum();
                })

            })
        </script>

        <!-- 邮箱验证 -->
        <div id="VerifyCode" style="" class="position login-codeForPhone">
            <input name="VerifyCode"  value="<?php echo $register_model->VerifyCode; ?>" type="text" class="login-forphone"  placeholder="验证码">
            <?php echo $objForm->error($register_model,'VerifyCode', array('class' => 'login-acc-text')); ?>
        </div>
        <div id="Code_img" style="" class="register-time">
            <!-- <span>重新发送</span>
            <strong>49</strong> -->
            <em><?php $this->widget('CCaptcha',array('showRefreshButton'=>true,'clickableImage'=>true,'buttonLabel'=>false));  ?></em>
        </div>


        <!-- 手机验证 -->
        <div id="PhoneCode" style="display:none" class="position login-codeForPhone">
            <input name="PhoneCode"  value="<?php echo $register_model->PhoneCode; ?>" type="text" class="login-forphone"  placeholder="短信验证码">
            <?php echo $objForm->error($register_model,'PhoneCode', array('class' => 'login-acc-text')); ?>
        </div>



        <div  id="snscode_div" style="display:none" class="register-time">
            <!-- <span>重新发送</span>
            <strong>49</strong> -->
            <input style="width:100px;height:50px"   id="snscode" type="button" value="获取验证码">
        </div>




        <div class="position register-pw">
            <input name="Password" type="password" class="login-pww register_login_pww"  placeholder="密码">
            <?php echo $objForm->error($register_model,'Password', array('class' => 'login-acc-text')); ?>
        </div>
        <div class="position register-pw-repeat">
            <input name="Repassword" type="password" class="register-pwR" placeholder="重复密码">
            <?php echo $objForm->error($register_model,'Repassword', array('class' => 'login-acc-text')); ?>
        </div>
        <button type="submit" class="register-confirm">注册</button>
        <div class="register-bom">
            <div class="register-move">
                <input name="Remember" type="checkbox" id="bg">
                <label for="bg" class="signUp-bg" id="registerUpBg"></label>
                <span>我已经阅读并同意遵守网站<a style="text-decoration:none" target="_blank" href="<?php echo $this->createUrl('/front/articles/index', array('id' => 362)) ?>"><em>使用条款</em></a></span>  
                
            </div>
            <div class="register-bom-info">
                <span>如果您已拥有妈咪街账户，则可在此</span>
                <button>登录</button>
            </div>
        </div>
    <?php $this->endWidget(); ?>
</div>
</body>

<script type="text/javascript">
    var register_height = 386;
    var login_height = 350;
    var register_height_r = 450;
</script>



<script type="text/javascript">
    $(function(){
        $(".ui-dialog-header").attr("id", "index-ui-bg");
        $(".ui-dialog-title").css({
            "font-size" : "22px",
            "color" : "#666666",
            "font-weight" : "normal"
        })
       $(".ui-dialog-grid input").focus(function() {
           $(".login-content .login-account").css({
               "border" : "1px solid #cfcfcf"
           })
           $(".login-content .login-pw").css({
               "border" : "1px solid #cfcfcf"
           })
           $(this).parent().css({
               "border" : "1px solid #ff7694"
           });
       })        
    })


</script>





<script type="text/javascript">
    $(function(){

        var register = '<?php echo $register; ?>';
        if(register){
            var dialog = top.dialog.get(window);
            dialog.close();
        }

        if($("[name='Repassword']").next('.login-acc-text').length > 0){
            $(".register-pw-repeat").show();
            $(window.top.document).find(".ui-dialog-content").css({height:register_height_r});
        }


        $(".register-confirm").click(function() {
            if($(".register-content input").val() == "") {
                if($(".register-move").hasClass("register-mov")) {
                    $(".register-move").removeClass("register-mov")
                } else {
                    again();

                }
                
            } 
        })

        function again() {
            $(".register-move").addClass("register-mov");
        }
      

        //注册
        $(".login-register a").click(function() {
            $(".login-content").hide();
            // $(".register-content").show();
            $(window.top.document).find(".ui-dialog-content").animate({
                "height" : register_height+"px"
            },500,function() {
                $(".register-content").show();
            });
            $(window.top.document).find(".ui-dialog-title").text("注册");
            $("[name='type']").val('1');
        });

        $(".register-bom-info button").click(function(e) {
            e.preventDefault();
            $(".register-content").hide();
            // $(".register-content").show();
            $(window.top.document).find(".ui-dialog-content").animate({
                "height" : login_height+"px",
                "width"  : "400px"
            },500,function() {
                $(".login-content").show();
            });
            $(".register-pw-repeat").css({
                "display" : "none"
            });
            $(window.top.document).find(".ui-dialog-title").text("登录");
            $("[name='type']").val('2');
        });

        
        var registerUpBg = document.getElementById('registerUpBg'),
            bg = document.getElementById('bg'),
            change = true;
        bg.onclick = function() {
            if(change) {
                registerUpBg.style.background = "url(/themes/mmj/assets/images/" + "indi_icon.png)";
                change = false;
            } else {
                registerUpBg.style.background = "url(/themes/mmj/assets/images/" + "indi_icon_off.png)";
                change = true;
            }
        }


        



        $(".register-content input[type='text'],.login-content input[type='text'],.register-content input[type='password'],.login-content input[type='password']").focus(function() {
           $(".register-content input[type='text'],.login-content input[type='text'],.register-content input[type='password'],.login-content input[type='password']").parent().css({
                "border" : "1px solid #cfcfcf"
           });
           $(this).parent().css({
               "border" : "1px solid #ff7694"
           });
           
        });

        // for mobile and password

        var loginAcc = $(".login-acc").val(),
            loginPw = $(".register_login_pww").val();




        $(".register_login_pww").focus(function() {
            if($(".register_login_pww").val() == "") {
                $(".login-pw-text").css({
                    "display" : "block"
                });

                $(window.top.document).find(".ui-dialog-content").css({height:register_height_r});
               
            } 
           
        });
        $(".login-pww").keyup(function() {
            $(".login-pw-text").css({
                "display" : "none"
            });

        })

        $(".register-pw input").focus(function() {
            $(".register-pw-repeat").css({
                "display" : "block"
            });
        })
    })
        

</script>

<script type="text/javascript">
    $(function(){
        $("#SubmitForm").submit(function(){
            if($("#bg:checked").length == 0){
                return false;
            }
            return true;
        })
    })
</script>


<script type="text/javascript">

var wait = 60;  //60秒才能发送一次
if (getCookie("time") == null || getCookie("time") <= 0){
    setCookie("time",wait,wait);
}else if(getCookie("time") != wait)
{
    timeRef();
}

//计时器
function time(o) {
    
        if(!o)
            var o = document.getElementById("snscode");
        
        if(getCookie("time") == wait){
            var moblie = $('#EmailPhone').val();
            $.getJSON('<?php echo $this->createUrl('sendcode') ?>',{moblie:moblie},function(data){
                if(data.status){
                    
                }else{
                    alert(data.info);
                }
            });
        }
    
        if (getCookie("time") == null || getCookie("time") <= 0) {
            o.removeAttribute("disabled");
            //o.value="免费获取验证码";
            $(o).val("获取验证码");

        } else {

            timeRef();
            
        }
}
//刷新按钮
function timeRef(){
    if(!o)
        var o = document.getElementById("snscode");
    waittime = getCookie("time");
    o.setAttribute("disabled", true);
    $(o).val("重新发送(" + waittime + ")");
    waittime--;
    setCookie("time",waittime);
    setTimeout(function() {
        time(o)
    },
    1000)
}
//点击获取验证码
document.getElementById("snscode").onclick=function(){
    var moblie = $('#EmailPhone').val();
    if(moblie == ''){
        alert('手机号不能为空？？？？！');
        return false;
    }
    if(!(/^1[3|4|5|8|7][0-9]\d{8}$/.test(moblie))){ 
        alert("手机号码格式不正确");  
        return false; 
    }
    setCookie("time",wait,wait);
    time(this);
}

//js设置Cookie
function setCookie(name,value,time)
{
    var exp = new Date();
    exp.setTime(exp.getTime() + time * 1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
//js获取Cookie
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
        return (arr[2]);
    else
        return null;
}

</script>


<script type="text/javascript">
    var LOCK = false;
    $(function(){
        $(document).on('click', "#send",function(e){
            var url = $(this).attr('href');
            e.preventDefault();
            tips = dialog({
                fixed: true,
                cancelDisplay: false
            });                 
            if(LOCK){
                tips.title('正在处理');
                tips.showModal();
                return false;
            }else{
                LOCK = true;
                tips.title('正在提交');
                tips.showModal();
            }               
            $.post(url,{ajax:true},function(data){
                LOCK = false;
                tips.title('处理成功');
                tips.content(data.info);
            },'json');
        })
    })
</script>






</html>

